﻿using GetSlaughterItem.API.Application.Commands.Week02.LiveAnimalsa;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SlaughterItem.API.Application.Commands.Week02.Killplan;
using SlaughterItem.Common.Dtos;

namespace GetSlaughterItem.API.Controllers.WangHaoQi
{
    /// <summary>
    /// 批宰计划显示控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class KillplansController : ControllerBase
    {
        private readonly IMediator mediatora;
        private readonly ILogger<KillplansController> logger;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediatora"></param>
        /// <param name="logger"></param>
        public KillplansController(IMediator mediatora, ILogger<KillplansController> logger)
        {
            this.mediatora = mediatora;
            this.logger = logger;
        }

        /// <summary>
        /// 批宰计划显示
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> SlaughterShow(SlaughterQueryCommand cmd)
        {
            try
            {
                logger.LogInformation("批宰计划显示");
                return await mediatora.Send(cmd);
            }
            catch (Exception ex)
            {

                logger.LogError("批宰计划显示失败" + ex.Message);
                throw;
            }
        }
    }
}
